<?php

namespace BaseBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * TestUser
 *
 * @ORM\Table(name="test_address")
 * @ORM\Entity(repositoryClass="BaseBundle\Repository\TestUserAddressRepository")
 */
class TestUserAddress implements \JsonSerializable
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(name="name", type="string", length=30, nullable=true, options={"comment":"名称"})
     */
    private $name;

    /**
     * @var TestUser
     * @ORM\ManyToOne(targetEntity="BaseBundle\Entity\TestUser")
     * @ORM\JoinColumn(name="test_user_id",referencedColumnName="id")
     */
    private $testUser;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     *
     * @return TestUserAddress
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set testUser
     *
     * @param \BaseBundle\Entity\TestUser $testUser
     *
     * @return TestUserAddress
     */
    public function setTestUser(\BaseBundle\Entity\TestUser $testUser = null)
    {
        $this->testUser = $testUser;

        return $this;
    }

    /**
     * Get testUser
     *
     * @return \BaseBundle\Entity\TestUser
     */
    public function getTestUser()
    {
        return $this->testUser;
    }

    function jsonSerialize()
    {
        $data = [];
        foreach ($this as $key=>$val){
            if ($val !== null){
                $data[$key] = $val;
            }else{
                $data[$key] = '';
            }
        }

        return $data;
    }
}
